# Mysql

FROM            10.0.16.125:5080/general/ubuntu:16.04
MAINTAINER      Lijc lijc@siccs.cn
# set the default value of env
ENV             DB_PASSWORD NOT_SET
ENV             SQL_FILE NOT_SET
# set te default password db-root
RUN             echo "mysql-server mysql-server/root_password password $DB_PASSWORD" | debconf-set-selections
RUN             echo "mysql-server mysql-server/root_password_again password $DB_PASSWORD" | debconf-set-selections
# install deb
RUN             apt-get update && apt-get -y install mysql-server wget
# create pid directory
RUN             mkdir /var/run/mysqld && chown -R mysql.mysql /var/run/mysqld/
# import config file
RUN             rm -f /etc/mysql/mysql.conf.d/mysqld.cnf
ADD             mysqld.cnf /etc/mysql/mysql.conf.d/
# backup database
RUN             cd /var/lib/mysql && tar zcpf /opt/mysql-data.tgz *
# create persistent volume directory
RUN             rm -rf /var/lib/mysql /var/log/mysql
RUN             mkdir /opt/pv
RUN             cd /opt/pv && mkdir -p mysql_data mysql_log
RUN             ln -s /opt/pv/mysql_data /var/lib/mysql
RUN             ln -s /opt/pv/mysql_log /var/log/mysql
# import docker entry script
ADD             docker-entrypoint /opt/
RUN             chmod 0755 /opt/docker-entrypoint
EXPOSE          3306
CMD             /opt/docker-entrypoint

